<#assign className = table.className>   
<#assign classNameLower = className?uncap_first> 
<#assign classNameFirstLower = className?uncap_first>   
<#assign classNameLowerCase = className?lower_case>  
package ${basepackage}.service;

import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ${basepackage}.mapper.${className};
import ${basepackage}.model.${className};

import java.util.List;

@Service
public class ${className}Service {

    @Autowired
    private ${className}Mapper ${classNameFirstLower}Mapper;

    public List<${className}> getAll(${className} ${classNameFirstLower}) {
        if (${classNameFirstLower}.getPage() != null && ${classNameFirstLower}.getRows() != null) {
            PageHelper.startPage(${classNameFirstLower}.getPage(), ${classNameFirstLower}.getRows());
        }
        return ${classNameFirstLower}Mapper.selectAll();
    }

    public ${className} getById(Integer id) {
        return ${classNameFirstLower}Mapper.selectByPrimaryKey(id);
    }

    public void deleteById(Integer id) {
        ${classNameFirstLower}Mapper.deleteByPrimaryKey(id);
    }

    public void save(${className} ${classNameFirstLower}) {
        if (${classNameFirstLower}.getId() != null) {
            ${classNameFirstLower}Mapper.updateByPrimaryKey(${classNameFirstLower});
        } else {
            ${classNameFirstLower}Mapper.insert(${classNameFirstLower});
        }
    }
}
